<g:javascript src="jquery/jquery-jtemplates.js"/>
<script language="javascript">
 

  $(document).ready(function() { 
         $.post("http://${request.getServerName()}/blog/api/getCommentsAndRemark", {time:new Date().getTime(),commentId:"${params.id}",classId:"${params.classId}"}, function(json) {
            $("#remarkTable").show()
            $("#showComments").setTemplateElement("templateleCourse");
            $("#showComments").processTemplate({"employee":json.remarks,"commentsInstance":json.commentsInstance});

        }, 'json'); 

        $("#remarkForm").submit( function(){
            if($.trim($("#content").val()) == ""){
                alert("回复内容不能为空！")
                $("#content").val("")
                $("#content").focus();
                return false;
            }
            if($.trim($("#content").val()).length > 1500){
                alert("回复内容长度不能大于1500字！")
                $("#content").focus();
                return false;
            }

            $.post("http://${request.getServerName()}/blog/api/saveRemark", {time:new Date().getTime(),classId:"${params.classId}",commentId:"${params.id}",content:$("#content").val(),teacherName:"${loggedInUserInfo(field: 'name')}"}, function(json) { 
                if(json.success){
                    alert(json.message)
                    window.location.reload(true);  
                }else{
                    alert(json.message)
                }
            }, 'json'); 

            return false;
        });
 
  });

  
 
</script>